﻿Friend Class FTimeoutInfoMessage

    Private mTimeLeft As Integer = 0

    Public Shadows Sub ShowDialog(ByVal owner As IWin32Window, ByVal caption As String, ByVal text As String, ByVal timeout As Integer)
        TextBox1.BorderStyle = BorderStyle.None
        TextBox1.Text = text
        Me.Text = caption
        PictureBox1.Image = My.Resources.Info_48x48.ToBitmap
        If timeout > 0 Then
            mTimeLeft = timeout
            tmrTimeout.Enabled = True
        End If
        UpdateTimeoutLabel()

        MyBase.ShowDialog(owner)
    End Sub

    Private Sub tmrTimeout_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrTimeout.Tick
        Try
            mTimeLeft -= 1
            UpdateTimeoutLabel()
            If mTimeLeft <= 0 Then Me.Close()
        Catch ex As Exception
            Framework.Misc.HandleException(Me, ex)
        End Try
    End Sub
    Private Sub UpdateTimeoutLabel()
        If mTimeLeft > 0 Then
            lblTimeoutCounter.Text = String.Format("Closing in {0} seconds...", mTimeLeft)
        Else
            lblTimeoutCounter.Text = String.Empty
        End If
    End Sub
End Class